require(["core", "jQuery", "coAjax"], function(jSouper, $, coAjax) {
	App.set("$Event.admin.add_case", function() {
		var strRegex_1 = '^((https|http|ftp|rtsp|mms)?://)';
		var strRegex_2 = '^((https|http|ftp|rtsp|mms)?://)' + '?(([0-9a-z_!~*\'().&=+$%-]+: )?[0-9a-z_!~*\'().&=+$%-]+@)?' //ftp的user@ 
			+ '(([0-9]{1,3}.){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184 
			+ '|' // 允许IP和DOMAIN（域名） 
			+ '([0-9a-z_!~*\'()-]+.)*' // 域名- www. 
			+ '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].' // 二级域名 
			+ '[a-z]{2,6})' // first level domain- .com or .museum 
			+ '(:[0-9]{1,4})?' // 端口- :80 
			+ '((/?)|' // a slash isn't required if there is no file name 
			+ '(/[0-9a-z_!~*\'().;?:@&=+$,%#-]+)+/?)$';
		var re_1 = new RegExp(strRegex_1);
		var re_2 = new RegExp(strRegex_2);
		var case_href = '';
		if (App.get("$Cache.case.href") != '') {
			if (re_2.test(App.get("$Cache.case.href"))) {
				if (!re_1.test(App.get("$Cache.case.href"))) {
					case_href = 'http://' + App.get("$Cache.case.href");
				} else {
					case_href = 'http://' + App.get("$Cache.case.href");
				}

			} else {
				alert('error', '请输入合法链接地址！！！');
			};
		} else {

		}
		var case_title = App.get("$Cache.case.title");
		var case_src = App.get("$Cache.case.src");
		if (case_href == '') {} else {
			coAjax.post(appConfig.admin.add_case, {
				title: case_title,
				href: case_href,
				src: case_src
			}, function(result) {
				alert("success", "案例添加成功");
				//清空缓存
				App.set("$Cache.case", {});
			}, function(errorCode, xhr, errorMsg) {
				alert("error", errorMsg);
			});

		};
	});
});